#!/usr/bin/env python3

def checkpan(var):
    used = set()
    needed = set(range(1,len(str(var))+1))
    for char in str(var):
        if int(char) in needed:
            if int(char) in used:
                return False
            else:
                needed.remove(int(char))
                used.add(int(char))
    if len(needed) is 0:
        return True
    else:
        return False

def broke(num):
    for x in str(num):
        if str(num).count(x) > 1:
            return True
    return False

def check(num):
    x = 2
    product = str(num)
    while not broke(product):
        product += str(num*x)
        if len(str(product)) == 9 and checkpan(product):
            return int(product)
        x += 1
    return 0
    
answer = 0
for x in range(1,999999):
    a = check(x)
    if a > answer:
        answer = a
print(answer)